home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
114_01
/
config1.bds
< prev
next >
Wrap
Text File
|
1987-07-13
|
15KB
|
733 lines
/* Screen editor: configuration program -- BDS C version
*
* Source: config1.bds
* Version: December 20, 1981.
* Transliteration of small-C version of September 6, 1981
*/
#define VERSION "Version 2: September 6, 1981."
#include bdscio.h
#include config.h
/* This program has 5 parts.
*
* Part 1 asks which keys do which special functions.
* Part 2 asks which special functions the screen has.
* Part 3 asks what code sequences must be output
* to the screen to do the functions in part 2.
* Part 4 creates the file ed1.ccc from the answers to
* Part 1.
* Part 5 creates the file ed6.ccc from the answers to
* Parts 2 and 3.
*/
main()
{
/* initialize byte count */
bytec=0;
/* sign on and give general information */
signon();
/* get keyboard information */
while (part1()==NO) {
;
}
/* get screen features */
while (part2()==NO) {
;
}
/* get control sequences for screen features */
while (part3()==NO) {
;
}
/* make sure we want to continue */
blank();
plc("You are now ready to create files ");
pc("ed1.ccc and ed6.ccc.");
plc("Do you want to proceed ?");
if (yesno()==NO) {
return;
}
/* write keyboard info to file ed1.ccc */
if (part4()!=YES) {
return;
}
/* write control sequences for screen features
* to file ed6.ccc
*/
part5();
/* sign off and tell about compiling */
signoff();
}
/* sign on and tell how to abort */
signon()
{
plc("Welcome to the configuration program for the ");
pc("screen editor.");
plc(VERSION);
plc("Hit control-c to exit this program early.");
plc("Hit control-p to send output to the printer.");
}
/* part 1. find out what keys will be used for
* special functions.
*/
part1()
{
blank();
plc("This section deals with your keyboard.");
plc("For each function key, enter the DECIMAL ");
pc("value of the ascii ");
plc("code that you want to assign to that function key.");
plc("Hit carriage return to indicate the default value.");
blank();
plc("Hit any key to get more instructions.");
getchar();
blank();
plc("insert up key:");
indent();
pc("This key inserts a blank line above the current line,");
indent();
pc("then switches the editor to insert mode.");
indent();
pc("The default is line feed (10).");
up1=getval(10);
plc("insert down key:");
indent();
pc("This key inserts a blank line below the current line,");
indent();
pc("then switches the editor to insert mode.");
indent();
pc("The default is carriage return (13).");
down1=getval(13);
plc("up key:");
indent();
pc("This key moves the cursor up,");
indent();
pc("then switches the editor to edit mode.");
indent();
pc("The default is control-u (21).");
up2=getval(21);
plc("down key:");
indent();
pc("This key moves the cursor down,");
indent();
pc("then switches the editor to edit mode.");
indent();
pc("The default is control-d (4).");
down2=getval(4);
plc("left key:");
indent();
pc("This key moves the cursor left. ");
indent();
pc("The default is back space (8).");
left=getval(8);
plc("right key:");
indent();
pc("This key moves the cursor right. ");
indent();
pc("The default is control-r (18).");
right=getval(18);
plc("insert key:");
indent();
pc("This key switches the editor to insert mode.");
indent();
pc("The default is control-n (14).");
ins=getval(14);
plc("edit key:");
indent();
pc("This key switches the editor to edit mode.");
indent();
pc("The default is control-e (5).");
edit=getval(5);
plc("command key:");
indent();
pc("This key switches the editor to command mode.");
indent();
pc("The default is esc (27).");
cmnd=getval(27);
plc("delete character key:");
indent();
pc("This key deletes the character to the left ");
pc("of the cursor.");
indent();
pc("The default is del (127).");
del=getval(127);
plc("delete line key:");
indent();
pc("This key deletes the line on which the cursor rests.");
indent();
pc("The default is control-z (26).");
delline=getval(26);
plc("undo key:");
indent();
pc("This key undoes the editing done on a line.");
indent();
pc("The default is control-x (24).");
undo=getval(24);
plc("split key:");
indent();
pc("This key splits a line into two lines.");
indent();
pc("The default is control-s (19).");
split=getval(19);
plc("join key:");
indent();
pc("This key appends a line to the line above it,");
indent();
pc("then deletes the lower line.");
indent();
pc("The default is control-p (16).");
join=getval(16);
/* recap what the user has typed.
* ask if everything is all right.
*/
plc("The values of the keyboard keys are:");
plc("insert up: ");
putdec(up1,3);
plc("insert down: ");
putdec(down1,3);
plc("up: ");
putdec(up2,3);
plc("down: ");
putdec(down2,3);
plc("left: ");
putdec(left,3);
plc("right: ");
putdec(right,3);
plc("insert mode: ");
putdec(ins,3);
plc("command mode: ");
putdec(cmnd,3);
plc("edit mode: ");
putdec(edit,3);
plc("delete char: ");
putdec(del,3);
plc("delete line: ");
putdec(delline,3);
plc("undo: ");
putdec(undo,3);
plc("split: ");
putdec(split,3);
plc("join: ");
putdec(join,3);
plc("are all values correct ?");
return(yesno());
}
/* get features of the video screen */
part2()
{
blank();
plc("This section deals with the video screen.");
plc("The screen MUST have a cursor positioning function,");
plc("but no other special screen functions are required.");
blank();
plc("screen length:");
indent();
pc("How many rows does your screen have ?");
indent();
pc("The default is 16.");
scrnl=getval(16);
blank();
plc("screen width:");
indent();
pc("How many columns does your screen have ?");
indent();
pc("The default is 64.");
scrnw=getval(64);
blank();
plc("printer width:");
indent();
pc("How many columns does your printer have ?");
indent();
pc("The default is 132.");
lwidth=getval(132);
blank();
plc("erase line:");
indent();
pc("Does your screen have a function which erases ");
indent();
pc("the line on which the cursor rests ?");
hasel=yesno();
plc("erase to end of line:");
indent();
pc("Does your screen have a function which erases ");
indent();
pc("from the cursor to the end of the line ?");
haseol=yesno();
plc("hardware scroll up: (line feed)");
indent();
pc("Does your screen have a function that scrolls the");
indent();
pc("screen up when the cursor is on the bottom line ?");
hassup=yesno();
plc("hardware scroll down:");
indent();
pc("Does your screen have a function which scrolls the");
indent();
pc("screen down when the cursor is on the top line ?");
hassdn=yesno();
blank();
plc("You have answered as follows: ");
plc("screen length: ");
putdec(scrnl,1);
plc("screen width: ");
putdec(scrnw,1);
plc("printer width: ");
putdec(lwidth,1);
plc("erase line ? ");
putyesno(hasel);
plc("erase to end of line ? ");
putyesno(haseol);
plc("hardware scroll up ? ");
putyesno(hassup);
plc("hardware scroll down ? ");
putyesno(hassdn);
blank();
plc("are all these values correct ?");
return(yesno());
}
part3()
{
blank();
plc("This section asks you to supply code sequences for");
plc("the special functions that you said your screen had.");
plc("Enter each sequence one byte at a time.");
plc("End the sequence by typing just a carriage return.");
plc("Indicate each byte by giving a character expression.");
blank();
plc("Hit any character to get more instructions.");
getchar();
blank();
plc("An expression consists of terms separated by + or -.");
plc("Each term is either:");
plc("1. a decimal number or");
plc("2. an ascii character in single quotes or");
plc("3. the letters x or y without quotes.");
plc("Use x and y only for the goto xy code sequence.");
plc("The x represents the desired COLUMN for the cursor.");
plc("The y represents the desired ROW for the cursor.");
plc("For example, a common sequence for goto x y is:");
plc(" 27, '=', y+32, x+32");
blank();
plc("